package com.songshuai.webapi.crm.aop;

import com.songshuai.webapi.common.aop.BaseSSOAspect;
import com.songshuai.webapi.common.redis.RedisUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;


@Aspect
@Component
public class SSOAspect extends BaseSSOAspect {

    @Autowired
    private HttpServletRequest request;

    @Autowired
    private RedisUtil redisUtil;


    @Pointcut(value = "execution(public * com.songshuai.webapi.crm.controller.*.*(..))")
    public void rlAop(){

    }

    @Around("rlAop()")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature();
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return getQrResponse(proceedingJoinPoint,request,authentication,redisUtil,"crm");



    }
}
